package algorithm.sorty;

import algorithm.sorty.sort.compare.MergeSort;
import algorithm.sorty.sort.compare.QuickSort;
import algorithm.sorty.sort.compare.ShellSort;
import utils.Asserts;
import utils.Integers;

import java.util.Arrays;

/**
 * @Description:
 * @Author Ammar
 * @Create 2023/5/1 14:02
 */
public class Test {


    public static void main(String[] args) {
        Integer[] array = Integers.random(10000000, 1, 10000000);
        testSorts(array,
//                new BubbleSort(),
//                new SelectionSort(),
//                new InsertionSort(),
//                new HeapSort(),
                new MergeSort(),
                new QuickSort(),
                new ShellSort()
        );
    }

    static void testSorts(Integer[] array, Sort... sorts) {
        for (Sort sort : sorts) {
            Integer[] newArray = Integers.copy(array);
            sort.sort(newArray);
            Asserts.test(Integers.isAscOrder(newArray));
        }
        Arrays.sort(sorts);

        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }
}
